<!DOCTYPE html>
<html>
<head>
  <meta charset="<?php echo $cfg_soft_lang; ?>">
  <title><?php echo $cfg_softname; ?></title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta name="apple-mobile-web-app-status-bar-style" content="black">
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="format-detection" content="telephone=no">
  <link rel="stylesheet" href="../publics/layui/css/layui.css" media="all"/>
  <link rel="stylesheet" href="../publics/iconfont/iconfont.css" media="all"/>
  <link rel="stylesheet" href="css/admin.css" media="all"/>
</head>
<body class="childrenBody">
<div class="x-nav">
	<span class="layui-breadcrumb">
	  <a href="index_body.php">首页</a>
	  <a><cite>栏目管理</cite></a>
	</span>
  <a class="layui-btn layui-btn-sm refresh" href="javascript:location.replace(location.href);" title="刷新"><i class="iconfont icon-refresh" style="line-height:30px"></i></a>
</div>
<div class="layui-mt-10">
  <div class="layui-inline">
    <a class="layui-btn layui-btn-sm layui-btn-normal" href="catalog_add.php?listtype=all">增加顶级栏目</a>
  </div>
  <div class="layui-inline">
    <a class="layui-btn layui-btn-sm layui-btn-warm" href="catalog_add.php?dopost=quick">批量增加栏目</a>
  </div>
  <div class="layui-inline">
    <a class="layui-btn layui-btn-sm upcatcache">更新栏目缓存</a>
  </div>
  <div class="layui-inline">
    <a class="layui-btn layui-btn-sm layui-btn-danger" href="makehtml_list.php">更新栏目HTML</a>
  </div>
</div>
<div class="layui-form news_list">
  <form name='form1' method='post' action='catalog_do.php?dopost=upRankAll'>
    <table class="layui-table layui-form" id="tree-table" lay-size="sm"></table>
    <!--<button class="layui-btn" lay-submit="" lay-filter="upRankAll">更新排序</button>-->
    <!--<button type="reset" class="layui-btn layui-btn-primary">重置</button>-->
  </form>
</div>
<script type="text/javascript" src="../publics/layui/layui.js"></script>
<script type="text/javascript" src="js/catalog.js"></script>
<script type="text/javascript" src="js/layuiex.js"></script>
<script language="javascript" src="js/global.js"></script>
<script language="javascript" src="js/context_menu.js"></script>
<script language="javascript" src="js/ieemu.js"></script>
<script language="javascript" src="js/dialog.js"></script>
<script language="javascript" src="js/dedeajax2.js"></script>
<script type="text/javascript">
  layui.config({
    base: "../publics/layui/ext/treetable/"
  }).use(['form', 'element', 'layer', 'treeTable', 'jquery'], function () {
    var form = layui.form,
      layer = parent.layer === undefined ? layui.layer : parent.layer,
      element = layui.element,
      $ = layui.jquery,
      treeTable = layui.treeTable;
    var re = treeTable.render({
      elem: '#tree-table',
      url: "catalog_main.php?dopost=getAllCatalog",
      icon_key: 'typename',
      primary_key: 'id',
      parent_key: 'reid',
      is_checkbox: true,
      icon: {
        open: 'layui-icon layui-icon-triangle-d',
        close: 'layui-icon layui-icon-triangle-r',
        left: 20,
      },
      checked: {
        key: 'id',
        data: [0, 1, 4, 10, 11, 5, 2, 6, 7, 3, 8, 9],
      },
      end: function (e) {
        form.render();
      },
      cols: [
        {
          key: 'sortrank',
          title: '排序',
          width: '50px',
          align: 'left',
        },
        {
          key: 'id',
          title: 'ID',
          width: '50px',
          align: 'left',
        },
        {
          key: 'typename',
          title: '名称',
          width: '300px',
          align: 'left',
          template: function (item) {
            if (item.ispart == 0) {
              return '<span style="color:blue;">' + item.typename + ' <span class="layui-btn layui-btn-xs layui-btn-normal">列</span><span class="layui-btn layui-btn-xs layui-btn-primary">' + item.totalarc + '</span></span>';
            } else if (item.ispart == 1) {
              return '<span style="color:red;">' + item.typename + ' <span class="layui-btn layui-btn-xs layui-btn-danger">封</span><span class="layui-btn layui-btn-xs layui-btn-primary">' + item.totalarc + '</span></span>';
            } else if (item.ispart == 2) {
              return '<span style="color:grey;">' + item.typename + ' <span class="layui-btn layui-btn-xs layui-btn-disabled">外</span><span class="layui-btn layui-btn-xs layui-btn-primary">' + item.totalarc + '</span></span>';
            } else {
              return item.typename;
            }
          }
        },
        {
          key: 'channelname',
          title: '内容模型',
          width: '60px',
          align: 'left',
        },
        {
          key: 'typedir',
          title: '文件目录',
          width: '80px',
          align: 'left',
        },
        {
          key: 'tempindex',
          title: '封面模板',
          width: '80px',
          align: 'left',
        },
        {
          key: 'templist',
          title: '列表模板',
          width: '80px',
          align: 'left',
        },
        {
          key: 'temparticle',
          title: '文章模板',
          width: '100px',
          align: 'left',
        },
        {
          title: '显示/隐藏',
          width: '60px',
          align: 'left',
          template: function (item) {
            if (item.ishidden == 0) {
              return '<span class="layui-btn layui-btn-danger layui-btn-xs">显示</span>';
            }else{
              return '<span class="layui-btn layui-btn-disabled layui-btn-xs">隐藏</span>';
            }
            
          }
        },
        {
          title: '操作',
          width: '500px',
          align: 'left',
          template: function (item) {
            return '<a href="catalog_edit.php?id=' + item.id + '" class="layui-btn layui-btn-normal layui-btn-xs"><i class="layui-icon"></i> 编辑</a>' +
              '<a href="/plus/list.php?tid=' + item.id + '" target="_blank" class="layui-btn layui-btn-xs"><i class="layui-icon"></i> 预览</a>' +
              '<a href="catalog_do.php?cid=' + item.id + '&dopost=listArchives" class="layui-btn layui-btn-xs"><i class="layui-icon"></i> 内容</a>' +
              '<a href="catalog_add.php?id=' + item.id + '" class="layui-btn layui-btn-xs"><i class="layui-icon"></i> 子栏目</a>' +
              '<a onclick="ex_show(\'移动\',\'catalog_do.php?dopost=moveCatalog&typeid=' + item.id + '\',\'600\',\'380\')" class="layui-btn layui-btn-xs layui-btn-warm"><i class="layui-icon">&#xe633;</i> 移动</a>'+
              '<a class="layui-btn layui-btn-xs layui-btn-danger catalog_del" data-id="' + item.id + '"><i class="layui-icon"></i> 删除</a>';
          }
        }
      ]
    });
  });
  function LoadSuns(ctid, tid) {
    if ($DE(ctid).innerHTML.length < 10) {
      $DE('img' + tid).className = 'iconfont icon-minus';
      var myajax = new DedeAjax($DE(ctid));
      myajax.SendGet('catalog_do.php?dopost=GetSunLists&cid=' + tid);
    } else {
      showHide(ctid, tid);
    }
  }
  function showHide(objname, tid) {
    if ($DE(objname).style.display == "none") {
      $DE('img' + tid).className = 'iconfont icon-minus';
      $DE(objname).style.display = BROWSER.firefox ? "" : "block";
    } else {
      $DE('img' + tid).className = 'iconfont icon-menu';
      $DE(objname).style.display = "none";
    }
  }
  if (moz) {
    extendEventObject();
    extendElementModel();
    emulateAttachEvent();
  }
</script>
</body>
</html>